﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace frp_tool
{
    class INIConfig
    {
        public string inipath;
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

        /*INIPath absolute*/
        public INIConfig(string INIPath)
        {
            
            inipath = INIPath;
            Console.Write(inipath);
        }

        public void set(string Section, string Key, string Value)
        {
            WritePrivateProfileString(Section, Key, Value, this.inipath);
        }

        public string get(string Section, string Key,string def="")
        {
            StringBuilder temp = new StringBuilder(500);
            int i = GetPrivateProfileString(Section, Key, def, temp, 500, this.inipath);
           
            return temp.ToString();
        }



    }
}
